<template>
  <div class="dashboard">
    <topAndbottom>
      <template #title> <span class="goback" @click="gobackBtn">项目管理</span> > <span>文件管理</span> </template>
      <template #container>
        <div class="common-container">
          <div class="container-search">
            <el-form :model="searchParams" label-width="80px" @submit.native.prevent="" :inline="true" size="default">
              <!-- <el-form-item label="文件名称">
                <el-input v-model="searchParams.name" @keyup.enter.native="" clearable @clear="" />
              </el-form-item> -->
              <el-form-item>

                <el-select v-model="AuditPageList.taskBaselineId" placeholder="请选择项目基线" @change="baselineChange"
                  value-key="value" :popper-append-to-body="false">
                  <el-option v-for="option in AuditPageList.BaselineList" :key="option.id" :label="option.taskBaseline"
                    :value="option.id" />
                </el-select>
                <el-button :icon="Plus" type="success" @click="addBtn(AuditPageList.taskBaselineId)"
                  style="margin-left: 10px;">文件上传</el-button>
                <el-button type="success" size="default" @click="baseAddBtn(AuditPageList.taskId)">添加新基线</el-button>
                <el-button type="primary" @click.stop="resetBtn(AuditPageList.oldList)">全部</el-button>
                <!-- <el-button @click="getBaseline('1658662886957940737')">000</el-button> -->
                <el-button type="primary" v-for="(item, index) in AuditPageList.oldList" @click.stop="searchBtn(item)"
                  :key="index">{{
                    item.name }}</el-button>
                <!-- <el-button :icon="Search"  @click="serachBtn">搜索</el-button> -->
                <!-- <el-button style="color: #FF7670;" :icon="Close"  @click="resetBtn">重置</el-button> -->
              </el-form-item>
            </el-form>
          </div>
          <div class="container-table">
            <el-table v-loading="AuditPageList.Loading" :height="AuditPageList.height" :data="AuditPageList.list"
              :row-class-name="tableRowClassName">
              style="width: 100%">
              <el-table-column prop="name" min-width="200" show-overflow-tooltip label="阶段名称" align="center" />
              <el-table-column prop="fileName" min-width="200" show-overflow-tooltip label="文件名" align="center" />
              <el-table-column prop="versions" min-width="200" show-overflow-tooltip label="版本" align="center">
                <template #default="scope">
                  <div @click="editVersionBtn(scope.row)" style="cursor: pointer;">
                    {{ scope.row.versions ? scope.row.versions : '无版本号' }}
                    <span style="color: rgb(185, 253, 255);">(点击修改)</span>
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="type" min-width="200" show-overflow-tooltip label="类型" align="center" />
              <el-table-column prop="createTime" min-width="200" show-overflow-tooltip label="创建时间" align="center">
                <template #default="scope">
                  {{ moment(scope.row.createTime).format("YYYY-MM-DD HH:mm") }}
                </template>
              </el-table-column>
              <el-table-column prop="status" min-width="200" show-overflow-tooltip label="状态" align="center">
                <template #default="scope">
                  {{ scope.row.status === 0 ? "锁定" : "正常" }}
                </template>
              </el-table-column>
              <el-table-column label="操作" min-width="450" align="center" fixed="right">
                <template #default="scope">
                  <el-button type="primary" :icon="Upload"
                    @click="editBtn(scope.row, AuditPageList.taskBaselineId)">更新文件</el-button>
                  <el-button type="primary" :icon="Edit" @click="DocumentBtn(scope.row)">审核</el-button>
                  <!--:disabled="scope.row.status !== 1"  :disabled="scope.row.status !== 1"-->
                  <el-button type="primary" :icon="View" @click="showBtn(scope.row)">预览</el-button>
                  <el-button type="primary" :icon="View" @click="moreBtn(scope.row)">预览更多</el-button>
                  <!-- <el-button  type="danger" :icon="Close" @click="deleteBtn(scope.row.id)">删除</el-button> -->
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- <div class="container-footer">footer数据</div> -->
        </div>
      </template>
    </topAndbottom>
    <editVersionDialog ref="editVersionChild" @save="saveEdutVersion"></editVersionDialog>
    <AuditAddEdit ref="RefAuditAddEdit" @saveFile="saveFile" :stageIds="AuditPageList.oldList"
      :taskId="AuditPageList.taskId" :currentbase="AuditPageList.currentbase"
      :dictDateBaseline="dictDateList?.task_baseline"></AuditAddEdit>
    <DocumentReview ref="RefDocumentReview" :AuditPageList="AuditPageList.list" :DocumentData="DocumentData.AudioRow">
    </DocumentReview>
    <!-- 预览文件 -->
    <Approval ref="RefApproval"></Approval>
    <!-- 更多预览 -->
    <moreHistoryVersion ref="RefMoreHistory"></moreHistoryVersion>
    <AddBaseline ref="addBaseLineChild" @save="save"></AddBaseline>
  </div>
</template>

<script setup lang='ts'>
import moment from "moment";
import AuditAddEdit from "./components/AuditAddEdit.vue";
import editVersionDialog from './components/editVersion.vue'
import DocumentReview from "./DocumentReview.vue";
import moreHistoryVersion from "./components/moreHistoryVersion.vue";
import { Search, Plus, Edit, Close, View, Upload } from "@element-plus/icons";
import { reactive, onMounted } from "vue";
import AuditHomePage from "@/composables/02Review/01ProjectMan/AuditHomePage";
import EditVersionTs from '@/composables/02Review/01ProjectMan/EditVersion'
import AuditAddEditTs from "@/composables/02Review/01ProjectMan/AuditAddEdit";
import ProjectTable from "@/composables/02Review/01ProjectMan/ProjectTable";
import BaseLineAdd from "@/composables/02Review/01ProjectMan/BaseLineModel";
import AddBaseline from "./components/AddBaseline.vue";
import DocumentReviewTs from "@/composables/02Review/01ProjectMan/DocumentReview";
import moreHistoryModel from "./modelTs/moreHistory";
import ApprovalModel from "./modelTs/approval";
const { RefApproval, showBtn } = ApprovalModel();

const { dictDateList, ProjectData } = ProjectTable();
const {
  AuditPageList,
  getAuditList,
  searchParams,
  resetBtn,
  searchBtn,
  getBaseline,
  baselineChange,
  gobackBtn,
  tableRowClassName
} = AuditHomePage();
const { addBtn, editBtn, RefAuditAddEdit, saveFile, } = AuditAddEditTs(
  getAuditList,
  baselineChange
);
const { editVersionBtn, editVersionChild, saveEdutVersion } = EditVersionTs(getAuditList,searchParams)
const { baseAddBtn, addBaseLineChild, save } = BaseLineAdd(getBaseline, getAuditList, searchParams);
const { RefDocumentReview, DocumentBtn, DocumentData } = DocumentReviewTs();
const { moreBtn, RefMoreHistory } = moreHistoryModel();
</script>
<style scoped lang='scss'>
.dashboard {
  height: 100%;
  overflow: hidden;

  :deep(.el-form-item__label) {
    color: #fff;
  }

  .goback {
    cursor: pointer;
  }
}
</style>